import 'package:flutter/material.dart';

void showExitDialog(BuildContext context, VoidCallback? callback) {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: const Text("Confirm"),
        content: const Text("Are you sure want to exit?"),
        actions: <Widget>[
          TextButton(
            child: const Text("Exit", style: TextStyle(color: Colors.white)),
            onPressed: () {
              Navigator.of(context).pop(); // 关闭对话框
              // 执行退出操作
              // 你可以在这里加入需要执行的退出操作代码
              callback?.call();
            },
          ),
          TextButton(
            child: const Text("No", style: TextStyle(color: Colors.white)),
            onPressed: () {
              Navigator.of(context).pop(); // 关闭对话框
            },
          ),
        ],
      );
    },
  );
}
